package jrain.fw.script.tools;

 
public class ELException extends Exception {
	// -------------------------------------
	// Member variables
	// -------------------------------------

	private static final long serialVersionUID = 1L;

	Throwable mRootCause;

	// -------------------------------------

	/**
	 * Constructor
	 */
	public ELException() {
		super();
	}

	// -------------------------------------

	/**
	 * Constructor
	 */
	public ELException(String pMessage) {
		super(pMessage);
	}

	// -------------------------------------

	/**
	 * Constructor
	 */
	public ELException(Throwable pRootCause) {
		mRootCause = pRootCause;
	}

	// -------------------------------------

	/**
	 * Constructor
	 */
	public ELException(String pMessage, Throwable pRootCause) {
		super(pMessage);
		mRootCause = pRootCause;
	}

	// -------------------------------------

	/**
	 * Returns the root cause
	 */
	public Throwable getRootCause() {
		return mRootCause;
	}

	// -------------------------------------

	/**
	 * String representation
	 */
	public String toString() {
		if (getMessage() == null) {
			return mRootCause.toString();
		} else if (mRootCause == null) {
			return getMessage();
		} else {
			return getMessage() + ": " + mRootCause;
		}
	}

	// -------------------------------------
}
